//
//  DiagnosisRecordViewController.m
//  SeaMelonSeeds_Counselor
//
//  Created by 尤振宇 on 2017/8/7.
//  Copyright © 2017年 杨笑. All rights reserved.
//

#import "DiagnosisRecordViewController.h"
#import "CustomTextView.h"
#import "OrderApi.h"

@interface DiagnosisRecordViewController ()
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet CustomTextView *textView;
@property (weak, nonatomic) IBOutlet UIButton *button;

@end

@implementation DiagnosisRecordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"诊断";
    self.titleLabel.text = [NSString stringWithFormat:@"   姓名: %@    性别: %@    年龄: %d岁",self.orderService.nickname,self.orderService.sex?@"女":@"男",self.orderService.age];
    [self.button roundedCorners_5PX];
    
    self.textView.placeholder = @"诊断记录";
    // Do any additional setup after loading the view from its nib.
    if (_isFinish) {
        self.textView.editable = NO;
        self.textView.text = self.orderService.result;
        self.button.hidden = YES;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)complete:(id)sender {
    if (![self.textView hasText]) {
        [MBProgressHUD showError:@"请认真填写诊断记录"];
        return;
    }
    WeakSelf(self)
    OrderApi *api = [[OrderApi alloc]initRequestCreateDiagnosis:self.orderService.id diagnosis:self.textView.text];
    [api startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        if (kCode(request.responseJSONObject)) {
            [Tool SendMessage_FillInDiagnosisRecord:weakself.order.id hx_username:weakself.order.user_hx serviceID:weakself.orderService.id];
            weakself.orderService.allow_create = NO;
            weakself.updataTableViewController.isViewWillAppearUpdata = YES;
            [weakself.navigationController popViewControllerAnimated:YES];
        }
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
